<html>
<head><meta charset="utf-8"><title>Nested use of `#[derive()]` · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Nested.20use.20of.20.60.23.5Bderive().5D.60.html">Nested use of `#[derive()]`</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="244889100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Nested%20use%20of%20%60%23%5Bderive%28%29%5D%60/near/244889100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Nested.20use.20of.20.60.23.5Bderive().5D.60.html#244889100">(Jul 05 2021 at 02:44)</a>:</h4>
<p>Is it possible to derive another proc-macro within the implementation of a <code>proc-macro</code>? This seems like it'd be easy if the implementaiton of the proc-macro were public but alas, I don't think that's possible? So I'm wondering if I can somehow add the additinoal <code>#[derive()]</code> annotation.</p>



<a name="244925785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Nested%20use%20of%20%60%23%5Bderive%28%29%5D%60/near/244925785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Wagner-Hall <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Nested.20use.20of.20.60.23.5Bderive().5D.60.html#244925785">(Jul 05 2021 at 11:45)</a>:</h4>
<p>Have you tried returning a TokenStream that prepends your new derive? I _think_ it should Just Work</p>



<a name="244926832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Nested%20use%20of%20%60%23%5Bderive%28%29%5D%60/near/244926832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Nested.20use.20of.20.60.23.5Bderive().5D.60.html#244926832">(Jul 05 2021 at 11:57)</a>:</h4>
<p>Derive macros can't change the original input, the return value is inserted after the original type definition.</p>



<a name="244963392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Nested%20use%20of%20%60%23%5Bderive%28%29%5D%60/near/244963392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> XAMPPRocky <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Nested.20use.20of.20.60.23.5Bderive().5D.60.html#244963392">(Jul 05 2021 at 18:27)</a>:</h4>
<p>You can use a attribute proc macro instead, they can change everything about the item that follows.</p>



<a name="244966867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Nested%20use%20of%20%60%23%5Bderive%28%29%5D%60/near/244966867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Nested.20use.20of.20.60.23.5Bderive().5D.60.html#244966867">(Jul 05 2021 at 19:18)</a>:</h4>
<p>Does anyone have an example handy?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>